// @ts-ignore
/* eslint-disable */
import request from '@/utils/request'

/** 通过url删除文件 DELETE /api/file */
export async function deleteFileByUrlUsingDelete(
  body: API.DeleteFileDto,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseString_>('/api/file', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json'
    },
    data: body,
    ...(options || {})
  })
}

/** 上传base64图片 POST /api/file/base64 */
export async function uploadBase64ImageUsingPost(base64Str: string) {
  return request({
    url: '/api/file/base64',
    method: 'post',
    data: {
      base64Str: base64Str
    }
  })
}

/** 合并分片，文件已上传=>立即返回url 视为秒传 POST /api/file/chunk/merge */
export async function mergeChunkUsingPost(data: any) {
  return request({
    url: '/api/file/chunk/merge',
    method: 'post',
    data
  })
}

/** 上传分片,文件/分片已上传=>立即返回（该返回为分片md5无实际意义） 视为断点续传 POST /api/file/chunk/upload */
export async function uploadChunkUsingPost(data: any) {
  return request({
    url: '/api/file/chunk/upload',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/** 小文件直传 参数名为file,批量前端做 POST /api/file/upload */
export async function uploadFileUsingPost(data: any) {
  return request({
    url: '/api/file/upload',
    method: 'post',
    data: {
      file: data,
      fileName: data.name
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
